from PySide6.QtCore import (Qt,QObject,QMetaObject,
                            Signal,Slot,
                            QThread,QThreadPool,QTimer,
                            QTemporaryFile,QTemporaryDir,
                            QJsonArray,QJsonDocument,QJsonParseError,QJsonValue,
                            QFile,QFileDevice,QIODevice,QIODeviceBase)
from .Staff_Task import *








class Staff_Monitor(QObject):
    Start_Task = Signal()
    Task_Finsh = Signal()
    Current_Completion_Process = Signal(int)
    Emergency_Stop = Signal()
    OnlyRun = Signal()
    
    
    
        
    def __init__(self, parent=None):
        super().__init__(parent)
        self.Start_Task.connect(self.RunTask)
        
        self._Directory_Path : str = None
        self._SrcFileList : list[str] = None
        
        self.driver : WebDriver
        self.wait : WebDriverWait
        self.actions : ActionChains
        self.args : dict
        
        print(f"提示 : 当前线程ID为 {threading.get_ident()}")
        
    @Slot(str)
    def solt_fun(self,text):
        print(f"我是槽函数,我是 {text}")


    # 设置员工属性
    def Set_Staff_Attribute(self,**kwargs):
        self.driver : WebDriver =  kwargs['driver']
        self.wait : WebDriverWait = kwargs['wait']
        self.actions : ActionChains = kwargs['actions']
        self.args : dict = kwargs['args']
        
        print("子线程设置属性")
        

    def RunTask(self):
        # print(QThread.currentThread())
        # self.worker = WorkerThread()
        # self.worker.start()
        # QThreadPool.globalInstance().start(Worker())
        # QThreadPool.globalInstance().start(Worker())
        print(f"提示 : 当前子线程ID {threading.get_ident()}")
        import time
        time.sleep(5)
        print(f"提示 : 线程 {threading.get_ident()} 等待了五秒!")
        self.Task_Finsh.emit()
        pass